using UnityEngine;
using System.Collections;

public class EntityVFX : MonoBehaviour
{
    [SerializeField] Material damageVFXMaterial;
    [SerializeField] float damageVFXDuration;

    SpriteRenderer sr;
    Material defaultMaterial;

    // ========================================================================

    private void Awake()
    {
        sr = GetComponentInChildren<SpriteRenderer>();
        defaultMaterial = sr.material;
    }

    // ========================================================================

    public IEnumerator OnDamageVFX()
    {
        sr.material = damageVFXMaterial;
        yield return new WaitForSeconds(damageVFXDuration);
        sr.material = defaultMaterial;
    }
}
